package com.google.code.pdfbrick.testcase;

import static org.junit.Assert.assertEquals;
import static java.lang.System.out;

import java.util.List;

import org.junit.Test;

import com.google.code.pdfbrick.engine.command.FilePageRange;
import com.google.code.pdfbrick.engine.command.FilePageRangeParser;
import com.google.code.pdfbrick.engine.command.PageRange;

public class TestCommandParser {

	private final static String VALID_COMM = "file:/c:/test1.pdf<1-8,10,25,28-40>";

	private final static String COMM_LACK_OF_LT = "file:/c:/test1.pdf1-8,10,25,28-40>";

	private final static String COMM_LACK_OF_MT = "file:/c:/test1.pdf<1-8,10,25,28-40";

	private final static String COMM_WITH_INCORRECT_PAGE_NUMBER1 = "file:/c:/test1.pdf<1-8,1e,,28-40>";

	private final static String COMM_NEED_OPTIMIZE = "file:/c:/test1.pdf<1-20,100,27,12,11,28-40>";

	@Test
	public void testNormalCommand() {
		String commStr = COMM_NEED_OPTIMIZE;
		FilePageRangeParser cp =FilePageRangeParser.getInstance();

		FilePageRange fpr = cp.parseFilePageRangeStr(commStr);
		assertEquals("file:/c:/test1.pdf", fpr.getFilePath());
		List<PageRange> list = fpr.getPageRangeList();
		for (PageRange pr : list) {
			out.println("from page " + pr.getStartIndex() + " to "
					+ pr.getEndIndex());
		}

	}

}
